13. Exercise: Implement drawBackAndUnclippedRectangle()

23 13 AAK DrawClippedRectangle

Exercise

In this exercise you will Implement the drawBackAndUnclippedRectangle() method.

  1. To see the drawClippedRectangle() method in action, draw the first unclipped rectangle by implementing the drawUnclippedRectangle() method as shown below.

    a. Save the canvas.

    b. Translate to the first row and column position.

    c. Draw by calling drawClippedRectangle().

    d. Then restore the canvas to its previous state.

private fun drawBackAndUnclippedRectangle(canvas: Canvas){
   canvas.drawColor(Color.GRAY)
   canvas.save()
   canvas.translate(columnOne,rowOne)
   drawClippedRectangle(canvas)
   canvas.restore()
}
  1. Run your app. You should see the first white rectangle with its circle, red line, and text on a gray background.